

import { RequestConfig, history } from 'umi';
const baseURL = "https://api.blog.wipi.tech/";


const authorization ="Bearer "+ sessionStorage.getItem('token')
export const request: RequestConfig = {
    timeout: 10000,
    errorConfig: {},
    middlewares: [],
    //请求拦截器
    requestInterceptors: [(url, options) => {
        if (!/http/.test(url)) {
            url = baseURL + url
        }
        let headers = options.headers;
        if (authorization) {
            headers = { ...headers, authorization }
        }     
        return {
            url,
            options: { ...options, interceptors: true, headers: { ...options.headers , authorization } },
        };
    }],
    //相应拦截器
    responseInterceptors: [],
};
